/* eslint-disable */
// @ts-nocheck
/*
 * @Author: askMeWhy
 * @Date:   2018-02-12 16:39:32
 * @Last Modified by: AskMeWhy
 * @Last Modified time: 2020-12-24 15:16:16
 */
(function() {
    if (!Event.prototype.preventDefault) {
        Event.prototype.preventDefault = function() {
            this.returnValue = false;
        };
    }
    if (!Event.prototype.stopPropagation) {
        Event.prototype.stopPropagation = function() {
            this.cancelBubble = true;
        };
    }
    if (!Element.prototype.addEventListener) {
        var eventListeners = [];

        var addEventListener = function(
            type,
            listener /*, useCapture (will be ignored) */
        ) {
            var self = this;
            var wrapper = function(e) {
                e.target = e.srcElement;
                e.currentTarget = self;
                if (typeof listener.handleEvent != "undefined") {
                    listener.handleEvent(e);
                } else {
                    listener.call(self, e);
                }
            };
            if (type == "DOMContentLoaded") {
                var wrapper2 = function(e) {
                    if (document.readyState == "complete") {
                        wrapper(e);
                    }
                };
                document.attachEvent("onreadystatechange", wrapper2);
                eventListeners.push({
                    object: this,
                    type: type,
                    listener: listener,
                    wrapper: wrapper2
                });

                if (document.readyState == "complete") {
                    var e = new Event();
                    e.srcElement = window;
                    wrapper2(e);
                }
            } else {
                this.attachEvent("on" + type, wrapper);
                eventListeners.push({
                    object: this,
                    type: type,
                    listener: listener,
                    wrapper: wrapper
                });
            }
        };
        var removeEventListener = function(
            type,
            listener /*, useCapture (will be ignored) */
        ) {
            var counter = 0;
            while (counter < eventListeners.length) {
                var eventListener = eventListeners[counter];
                if (
                    eventListener.object == this &&
                    eventListener.type == type &&
                    eventListener.listener == listener
                ) {
                    if (type == "DOMContentLoaded") {
                        this.detachEvent(
                            "onreadystatechange",
                            eventListener.wrapper
                        );
                    } else {
                        this.detachEvent("on" + type, eventListener.wrapper);
                    }
                    eventListeners.splice(counter, 1);
                    break;
                }
                ++counter;
            }
        };
        Element.prototype.addEventListener = addEventListener;
        Element.prototype.removeEventListener = removeEventListener;
        if (HTMLDocument) {
            HTMLDocument.prototype.addEventListener = addEventListener;
            HTMLDocument.prototype.removeEventListener = removeEventListener;
        }
        if (Window) {
            Window.prototype.addEventListener = addEventListener;
            Window.prototype.removeEventListener = removeEventListener;
        }
    }
})();
// 兼容低版本findIndex
if (!Array.prototype.findIndex) {
    Object.defineProperty(Array.prototype, 'findIndex', {
        value: function(predicate) {
            // 1. Let O be ? ToObject(this value).
            if (this == null) {
                throw new TypeError('"this" is null or not defined');
            }

            var o = Object(this);

            // 2. Let len be ? ToLength(? Get(O, "length")).
            var len = o.length >>> 0;

            // 3. If IsCallable(predicate) is false, throw a TypeError exception.
            if (typeof predicate !== 'function') {
                throw new TypeError('predicate must be a function');
            }

            // 4. If thisArg was supplied, let T be thisArg; else let T be undefined.
            var thisArg = arguments[1];

            // 5. Let k be 0.
            var k = 0;

            // 6. Repeat, while k < len
            while (k < len) {
                // a. Let Pk be ! ToString(k).
                // b. Let kValue be ? Get(O, Pk).
                // c. Let testResult be ToBoolean(? Call(predicate, T, « kValue, k, O »)).
                // d. If testResult is true, return k.
                var kValue = o[k];
                if (predicate.call(thisArg, kValue, k, o)) {
                    return k;
                }
                // e. Increase k by 1.
                k++;
            }

            // 7. Return -1.
            return -1;
        }
    });
}
// creates a global "addWheelListener" method
// example: addWheelListener( elem, function( e ) { console.log( e.deltaY ); e.preventDefault(); } );
(function(window, document) {
    var prefix = "",
        _addEventListener,
        onwheel,
        support;

    // detect event model
    if (window.addEventListener) {
        _addEventListener = "addEventListener";
    } else {
        _addEventListener = "attachEvent";
        prefix = "on";
    }

    // detect available wheel event
    support =
        "onwheel" in document.createElement("div")
            ? "wheel" // 各个厂商的高版本浏览器都支持"wheel"
            : document.onmousewheel !== undefined
            ? "mousewheel" // Webkit 和 IE一定支持"mousewheel"
            : "DOMMouseScroll"; // 低版本firefox

    window.addWheelListener = function(elem, callback, useCapture) {
        _addWheelListener(elem, support, callback, useCapture);

        // handle MozMousePixelScroll in older Firefox
        if (support == "DOMMouseScroll") {
            _addWheelListener(
                elem,
                "MozMousePixelScroll",
                callback,
                useCapture
            );
        }
        function destroyObserver(){
            elem.removeEventListener(support, callback);
            if (support == "DOMMouseScroll") {
                elem.removeEventListener("MozMousePixelScroll", callback);
            }
        }
        return {
            destroy: destroyObserver
        };
    };

    function _addWheelListener(elem, eventName, callback, useCapture) {
        elem[_addEventListener](
            prefix + eventName,
            support == "wheel"
                ? callback
                : function(originalEvent) {
                      !originalEvent && (originalEvent = window.event);

                      // create a normalized event object
                      var event = {
                          // keep a ref to the original event object
                          originalEvent: originalEvent,
                          target:
                              originalEvent.target || originalEvent.srcElement,
                          type: "wheel",
                          deltaMode:
                              originalEvent.type == "MozMousePixelScroll"
                                  ? 0
                                  : 1,
                          deltaX: 0,
                          deltaZ: 0,
                          preventDefault: function() {
                              originalEvent.preventDefault
                                  ? originalEvent.preventDefault()
                                  : (originalEvent.returnValue = false);
                          }
                      };

                      // calculate deltaY (and deltaX) according to the event
                      if (support == "mousewheel") {
                          event.deltaY = (-1 / 40) * originalEvent.wheelDelta;
                          // Webkit also support wheelDeltaX
                          originalEvent.wheelDeltaX &&
                              (event.deltaX =
                                  (-1 / 40) * originalEvent.wheelDeltaX);
                      } else {
                          event.deltaY = originalEvent.detail;
                      }

                      // it's time to fire the callback
                      return callback(event);
                  },
            useCapture || false
        );
    }
})(window, document);